@import "../../style/themes/default";
@import "../../style/mixins/index";
@import "../../input/style/mixin";

@select-prefix-cls: ~"@{ant-prefix}-select";
@checkbox-prefix-cls: ~"@{ant-prefix}-checkbox";

.@{select-prefix-cls} {
  .reset-component;
  display: inline-block;
  position: relative;

  ul,
  ol {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  > ul > li > a {
    padding: 0;
    background-color: @component-background;
  }

  .@{select-prefix-cls}-underline {
    position: absolute;
    height: 0;
    width: 100%;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: rgba(0, 0, 0, 0.54);
  }

  .@{select-prefix-cls}-ripple {
    position: absolute;
    left: 0;
    width: 100%;
    transform-origin: 50%;
    transform: scaleX(0.5);
    opacity: 0;
    border-bottom-width: 2px;
    border-bottom-style: solid;
    transition: border-color 300ms cubic-bezier(0.55, 0, 0.55, 0.2);
    border-color: #3367d6;
    height: 0;
  }

  &.@{select-prefix-cls}-focused {

    & .@{select-prefix-cls}-ripple {
      opacity: 1;
      transform: scaleX(1);
      transition: transform 300ms cubic-bezier(0.25, 0.8, 0.25, 1), opacity 100ms cubic-bezier(0.25, 0.8, 0.25, 1), border-color 300ms cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .@{select-prefix-cls}-selection-label {
      margin-top: 0 !important;
      transform: scale(.75) translateY(-20px) translateZ(0.001px);
      color: @primary-color;
      transition: transform 300ms @ease-out, color 100ms @ease-out, background-color 300ms @ease-out;
    }
  }

  &-multiple&-open {
    .@{select-prefix-cls}-selection-label {
      margin-top: 0 !important;
      transform: scale(.75) translateY(-20px) translateZ(0.001px);
      color: @primary-color;
      transition: transform 300ms @ease-out, color 100ms @ease-out, background-color 300ms @ease-out;
    }
  }

  &.@{select-prefix-cls}-has-value {
    .@{select-prefix-cls}-selection-label {
      margin-top: 0 !important;
      transform: scale(.75) translateY(-20px) translateZ(0.001px);
    }
  }

  .@{select-prefix-cls}-has-label &-selection {
    padding-top: 15px;
  }

  &-selection {
    outline: none;
    user-select: none;
    box-sizing: content-box;
    border: none;
    background-color: @input-bg;
    // strange align fix for chrome but works
    // https://gw.alipayobjects.com/zos/rmsportal/VFTfKXJuogBAXcvfAUWJ.gif
    border-top-width: @border-width-base + 0.02px;
    transition: all .3s @ease-in-out;
    color: #000;
    letter-spacing: .01em;
    align-items: center;
    cursor: pointer;
    display: block;
    max-width: 100%;
    width: 100%;
    min-width: 50px;
    position: relative;

    &-selected-value {
      display: inline-block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 100%;
      vertical-align: middle;
      &:after {
        content: '';
        visibility: hidden;
        display: inline-block;
      }
    }

    &-label {
      color: @label-color;
      position: absolute;
      left: 0;
      top: 15px;
      margin-top: 2px;
      z-index: 1;
      transform-origin: 0 0;
      width: 100%;
      pointer-events: none;
      transition: transform 400ms @ease-out, color 400ms @ease-out, background-color 400ms @ease-out;
      .is-required &:after {
        display: inline-block;
        margin-left: 4px;
        content: "*";
        font-family: SimSun;
        line-height: 1;
        font-size: @font-size-base;
        color: @label-required-color;
        // .@{form-prefix-cls}-hide-required-mark & {
        //   display: none;
        // }
      }
    }
  }

  &-disabled {
    color: @input-disabled-color;
  }

  &-disabled &-selection {
    color: @input-disabled-color;
    cursor: not-allowed;
    &:hover,
    &:focus,
    &:active {
      border-color: @border-color-base;
      box-shadow: none;
    }
  }

  &-disabled &-clear {
    display: none;
    visibility: hidden;
    pointer-events: none;
  }

  .has-error &-underline {
    border-bottom-color: #d50000;
  }

  &-disabled &-underline {
    border-bottom: 1px dotted rgba(0, 0, 0, 0.42);
  }

  &-disabled&-tags &-selection--multiple &-selection__choice {
    background: rgba(0, 0, 0, 0.26);
  }

  &-selection--single {
    position: relative;
    cursor: pointer;
  }

  &-selection__rendered {
    display: inline-block;
    width: 100%;
    position: relative;
    padding-right: 20px;
  }

  &-arrow {
    position: absolute !important;
    top: 0;
    right: 0;
    bottom: 0;
    margin: auto 0;
    transition: opacity 0.15s ease;
  }

  &-clear {
    position: absolute !important;
    top: 0;
    right: @control-padding-horizontal;
    bottom: 0;
    margin: auto 0;
    opacity: 0;
    transition: opacity 0.15s ease;
  }

  &:hover &-clear {
    opacity: 1;
  }

  &-lg {
    font-size: @font-size-lg;
    i.icon {
      font-size: 24px;
    }

    .@{select-prefix-cls}-selection--multiple {
      .@{select-prefix-cls}-selection__rendered {
        li {
          height: @input-height-lg - 8px;
          line-height: @input-height-lg - 8px;
        }
      }
    }
  }

  &-sm {
    i.icon {
      font-size: 16px;
    }
    .@{select-prefix-cls}-selection--multiple {
      .@{select-prefix-cls}-selection__rendered {
        li {
          height: @input-height-sm - 8px;
          line-height: @input-height-sm - 10px;
        }
      }
    }
  }

  &-disabled &-selection__choice__remove {
    display: none;
    color: @input-disabled-color;
    cursor: default;
    &:hover {
      color: @input-disabled-color;
    }
  }

  &-search__field__wrap {
    display: inline-block;
    position: relative;
  }

  &-selection__placeholder,
  &-search__field__placeholder { // for TreeSelect compatibility
    position: absolute;
    margin-top: 2px;
    left: 0;
    z-index: 1;
    width: 100%;
    pointer-events: none;
    color: @input-placeholder-color;
  }

  &-search__field__placeholder {
    left: @control-padding-horizontal;
  }

  &-search__field__mirror {
    position: absolute;
    top: 0;
    left: -9999px;
    white-space: pre;
    pointer-events: none;
  }

  &-search--inline {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;

    .@{select-prefix-cls}-search__field__wrap {
      width: 100%;
      height: 100%;
    }

    .@{select-prefix-cls}-search__field {
      border-width: 0;
      font-size: 100%;
      height: 100%;
      width: 100%;
      background: transparent;
      outline: 0;
      border-radius: @border-radius-base;
    }

    > i {
      float: right;
    }
  }

  &-tags {
    .@{select-prefix-cls}-selection--multiple {
      min-height: @input-height-base;
      cursor: text;
      .clearfix;

      .@{select-prefix-cls}-search--inline {
        float: left;
        position: static;
        width: auto;
        padding: 0;

        max-width: 100%;
        .@{select-prefix-cls}-search__field {
          max-width: 100%;
          width: 0.75em;
        }
      }

      .@{select-prefix-cls}-selection-label,
      .@{select-prefix-cls}-selection__placeholder {
        margin-top: 9px;
      }

      .@{select-prefix-cls}-selection__rendered {
        margin-bottom: -3px;
        height: auto;
        padding: 0;
      }

      > ul > li,
      .@{select-prefix-cls}-selection__rendered > ul > li { // for tree-select
        margin-top: 5px;
        height: @input-height-base - 8px;
        line-height: @input-height-base - 8px - 2px;
      }

      .@{select-prefix-cls}-selection__choice {
        border-radius: @border-radius-lg;
        cursor: default;
        float: left;
        max-width: 99%;
        position: relative;
        overflow: hidden;
        transition: padding .3s @ease-in-out;
        color: @tag-default-color;
        background-color: @tag-default-bg;
        margin-right: 8px;
        padding: 0 32px 0 8px;
        &__disabled {
          padding: 0 10px;
        }
      }

      .@{select-prefix-cls}-selection__choice__content {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        max-width: 100%;

        transition: margin .3s @ease-in-out;
        display: inline-block;
        &:after {
          content: none;
        }
      }

      .@{select-prefix-cls}-selection__choice__remove {
        .iconfont-font("\e5c9");
        color: @tag-default-color;
        line-height: inherit;
        cursor: pointer;
        display: inline-block;
        transition: all .3s;
        font-size: @font-size-lg;
        position: absolute;
        right: 10px;
      }
    }
  }

  &-open {
    .@{select-prefix-cls}-arrow:before {
      transform: rotate(180deg);
    }
    .@{select-prefix-cls}-selection {
      .active();
    }
  }

  &-combobox {

    .@{select-prefix-cls}-arrow {
      display: none;
    }

    .@{select-prefix-cls}-selection__rendered {
       padding: 0;
    }

    .@{select-prefix-cls}-search--inline {
      width: 100%;
      text-overflow: inherit;
      overflow: inherit;
    }

    .@{select-prefix-cls}-search__field__wrap {
      width: 100%;
      height: 100%;
    }

    .@{select-prefix-cls}-search__field {
      width: 100%;
      height: 100%;
      position: relative;
      z-index: 1;
      transition: all .3s @ease-in-out;
      box-shadow: none;
    }

    .@{select-prefix-cls}-selection__placeholder,
    .@{select-prefix-cls}-search__field__placeholder { // for TreeSelect compatibility
      margin-top: 0;
    }
  }
}

.@{select-prefix-cls}-dropdown {
  .reset-component;

  &.slide-up-enter.slide-up-enter-active&-placement-bottomLeft,
  &.slide-up-appear.slide-up-appear-active&-placement-bottomLeft {
    animation-name: antSlideUpIn;
  }

  &.slide-up-enter.slide-up-enter-active&-placement-topLeft,
  &.slide-up-appear.slide-up-appear-active&-placement-topLeft {
    animation-name: antSlideDownIn;
  }

  &.slide-up-leave.slide-up-leave-active&-placement-bottomLeft {
    animation-name: antSlideUpOut;
  }

  &.slide-up-leave.slide-up-leave-active&-placement-topLeft {
    animation-name: antSlideDownOut;
  }

  &-hidden {
    display: none;
  }

  background-color: @component-background;
  border-radius: @border-radius-base;
  box-sizing: border-box;
  z-index: @zindex-dropdown;
  left: -9999px;
  top: -9999px;
  position: absolute;
  outline: none;
  font-size: @font-size-base;
  box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);

  &-filter {
    padding: 23px 16px 8px 16px;
    background-color: #fafafa;
    border-bottom: @border-width-base @border-style-base @border-color-base;
    i.icon {
      color: rgba(0, 0, 0, 0.66);
    }
    &-input {
      width: 90%;
      display: inline-block;
      margin-left: 8px;
    }
  }
  &-select-all-none {
    font-size: @font-size-sm;
    padding: 8px 16px;
    border-bottom: @border-width-base @border-style-base @border-color-base;
    span {
      margin-right: 4px;
      cursor: pointer;
      color: @primary-color;
    }
  }

  &-footer {
    padding: 16px;
    background-color: #fafafa;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
  }

  &-menu {
    outline: none;
    margin-bottom: 0;
    list-style: none;
    max-height: 250px;
    overflow: auto;
    padding: 8px 0;
    &-item-group {
      padding-top: 4px;
      padding-bottom: 4px;
      &:not(:last-child) {
        border-bottom: @border-width-base @border-style-base @border-color-base;
      }
    }
    &-item-group-list {
      margin: 0;
      padding: 0;

      > .@{select-prefix-cls}-dropdown-menu-item {
        padding-left: 20px;
      }
    }
    &-item-group-no-title > .@{select-prefix-cls}-dropdown-menu-item {
      padding-left: @control-padding-horizontal;
    }

    &-item-group-title {
      color: @text-color-secondary;
      padding: 0 @control-padding-horizontal;
      height: 32px;
      line-height: 32px;
      font-size: @font-size-sm;
    }

    &-item {
      position: relative;
      display: block;
      padding: 4px @control-padding-horizontal;
      line-height: 20px;
      font-weight: normal;
      color: @text-color;
      white-space: nowrap;
      cursor: pointer;
      overflow: hidden;
      text-overflow: ellipsis;
      transition: background 0.3s ease;
      letter-spacing: .01em;
      height: auto;

      &:hover {
        background-color: @item-hover-bg;
      }

      &:first-child {
        border-radius: @border-radius-base @border-radius-base 0 0;
      }

      &:last-child {
        border-radius: 0 0 @border-radius-base @border-radius-base;
      }

      &-disabled {
        color: @input-disabled-color;
        cursor: not-allowed;

        &:hover {
          color: @input-disabled-color;
          background-color: @component-background;
          cursor: not-allowed;
        }
      }

      &-selected {
        background-color: @item-focus-bg;
      }

      &-divider {
        height: 1px;
        margin: 1px 0;
        overflow: hidden;
        background-color: @border-color-split;
        line-height: 0;
      }
    }
  }

  &&--multiple {
    .@{select-prefix-cls}-dropdown-menu-item {
      .@{checkbox-prefix-cls}-wrapper {
        user-select: none;
        margin-right: 8px;
      }

      &:hover {
        background-color: @item-hover-bg;
      }

      &-active,
      &:active {
        background-color: @menu-item-active-bg;
      }

      &:focus {
        background-color: @menu-item-active-bg;
      }
    }

    .@{select-prefix-cls}-dropdown-menu-item-selected {
      background-color: transparent;
    }
  }

  &-container-open,
  &-open {
    .@{select-prefix-cls}-dropdown {
      display: block;
    }
  }
}
